package chain

import (
	"context"
	"github.com/simplechain-org/go-simplechain/common"
)

// GetAccounts 获取节点中地址
func (c *Client) GetAccounts() ([]string, error) {
	var account []string
	err := c.rpcClient.Call(&account, "eth_accounts")
	if err != nil {
		return nil, err
	}
	return account, nil
}

// GetNonce 获取nonce
func (c *Client) GetNonce(from common.Address) (uint64, error) {
	return c.client.PendingNonceAt(context.TODO(), from)
}

func (c *Client) GetSigners() ([]string, error) {
	var signers []string
	err := c.rpcClient.Call(&signers, "clique_getSigners", "latest")
	if err != nil {
		return nil, err
	}
	return signers, nil
}
